app.controller('GetCampusbulidingsCtrl', ['$scope','$http','$location','$localStorage','$window','$state',
 function($scope,$http,$location,$localStorage,$window,$state) {
    	$scope.namedata = $localStorage.cur_user.uname; 
		$http.post(
	        $scope.app.backendurl+"tbl-campus-building/view-all",
	        {  
	        	'school_id':$state.params.campusid,	 
	            'token':$localStorage.token                  

	        }
	    ).success(function (data) {	      
	      if(data.code==0&&data.msg=="ok"){
	      	$scope.mdata = data.data.type;
	      	$scope.schoolinfo = data.data.school_info;	      
	      	$scope.aaData =data.data[data.data.type[0].type_name];
	      	$('#bulidingtype').val(data.data.type[0].type_name);
	      	$('#typeid').val(data.data.type[0].id);
	      	$("#schoolname").text($scope.schoolinfo.school_name);
	      
	      }
	      if(data.code==20001&&data.msg=="请先登录"){
	      	$location.path('access.signin');
	      } 
	    }).error(function (data) {
	        alert(data);
	    });

	 
	  

	    $scope.onClickTab = function (tab) {	    	
	    	$('#bulidingtype').val(tab.type_name);	  
	    	$('#typeid').val(tab.id); 
	        $http.post(
		        $scope.app.backendurl+"tbl-campus-building/view-all",
		        {  
		        	'school_id':$state.params.campusid,		           
		            'type': tab.type_name,    
		            'token':$localStorage.token  
		        }
		    ).success(function (data) {	     
		      if(data.code==0&&data.msg=="ok"){ 
		      	$scope.aaData =data.data[tab.type_name];
		      }
		      
		      if(data.code==20001&&data.msg=="请先登录"){
		      	$location.path('access.signin');
		      }
		      
		    })
		}

	
	   
  }])
  ; 
